﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CinemaSystem
{
    public partial class scdd : Form
    {
        public scdd()
        {
            InitializeComponent();
        }
        string sqlstr;
        DataTable dt = new DataTable();
        private void scdd_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            sqlstr = string.Format("select * from [Order]");
            dt = DBHelper.GetDataTable(sqlstr);

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource = dt;
        }
        int id;
        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((MessageBox.Show("您是否确定要删除？", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                == DialogResult.Yes))
            {


                sqlstr = string.Format("delete [Order] where Orderid={0}", id);
                int i = DBHelper.ExecuteNonQuery(sqlstr);
                if (i > 0)
                {
                    MessageBox.Show("删除成功！");
                    DataTable dt = new DataTable();
                    sqlstr = string.Format("select * from [Order]");
                    dt = DBHelper.GetDataTable(sqlstr);

                    dataGridView1.AutoGenerateColumns = false;
                    dataGridView1.DataSource = dt;
                }
                else
                {
                    MessageBox.Show("删除成功！");
                }
            }
        }

        private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            id = e.RowIndex;
        }
    }
        }
